import 'package:hxdj/common/my_common.dart';
import 'package:rongcloud_im_wrapper_plugin/rongcloud_im_wrapper_plugin.dart';

enum MyMessageImageType {
  /// 默认高>宽
  heightOutweighWidth,

  /// 宽>高
  widthOutweighHeight,

  /// 高=宽
  heightEqualWidth,
}

class ChatMessageBaseModel extends RCIMIWMessage {
  //  是否展示消息的时间
  late bool isShowTime = false;

  late String? createTime = "";

  @override
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = super.toJson();
    return json;
  }

  ChatMessageBaseModel.fromJson(super.json) : super.fromJson() {
    createTime = CommonPlugin.messageTime(sentTime ?? 0);
  }
}

//文本信息

class ChatMessageTextModel extends ChatMessageBaseModel {
  /// 文本内容
  String? text;

  @override
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = super.toJson();
    json['text'] = text;
    return json;
  }

  ChatMessageTextModel.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
    text = json['text'];
  }
}

//图片信息
class ChatMessageImageModel extends ChatMessageBaseModel {
  /// 图片的缩略图数据
  String? thumbnailBase64String;

  /// 是否为原图
  bool? original;

  /// 本地路径
  String? local;

  /// 远端路径
  String? remote;

  @override
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> json = super.toJson();
    json['thumbnailBase64String'] = thumbnailBase64String;
    json['original'] = original;
    json['local'] = local;
    json['remote'] = remote;
    return json;
  }

  ChatMessageImageModel.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
    thumbnailBase64String = json['thumbnailBase64String'];
    original = json['original'];
    remote = json['remote'];
    local = json['local'];
   
    
  }
}




//  if(messageType == RCIMIWMessageType.text){
        

//     }
// static String timeFormatterChatTimeStamp(int seconds) {
//     try {
//       int nowDateSeconds =
//           (DateTime.now().millisecondsSinceEpoch / 1000).truncate();

//       String anotherDate =
//           DateUtil.formatDateMs(seconds*1000, format: DateFormats.full);

//       String nowDate =
//           DateUtil.formatDateMs(nowDateSeconds*1000, format: DateFormats.full);

//       print(
//           "timeFormatterChatTimeStamp "
//               "seconds:${seconds},"
//               "nowDateSeconds:${nowDateSeconds},"
//               "anotherDate:${anotherDate},"
//               "nowDate:${nowDate}");
//       //为了判断当前时间是否为未来时间
//       if (seconds > nowDateSeconds) {
//         return anotherDate;
//       }

//       List<String> anotherDateList = anotherDate.split(" ");
//       List<String> nowDateList = nowDate.split(" ");
//       if (anotherDateList.length == 2 && nowDateList.length == 2) {
//         String nowDateYMD = nowDateList[0];
//         String nowDateHMS = nowDateList[1];

//         String anotherDateYMD = anotherDateList[0];
//         String anotherDateHMS = anotherDateList[1];

//         List<String> anotherDateYMDList = anotherDateYMD.split("-");
//         List<String> nowDateYMDList = nowDateYMD.split("-");

//         List<String> anotherDateHMSList = anotherDateHMS.split(":");
//         List<String> nowDateHMSList = nowDateHMS.split(":");

//         String anotherDateY = anotherDateYMDList[0];
//         String anotherDateM = anotherDateYMDList[1];
//         String anotherDateD = anotherDateYMDList[2];

//         String nowDateY = nowDateYMDList[0];
//         String nowDateM = nowDateYMDList[1];
//         String nowDateD = nowDateYMDList[2];

//         String anotherDateH = anotherDateHMSList[0];
//         String anotherDateMi = anotherDateHMSList[1];
//         String anotherDateS = anotherDateHMSList[2];

//         int year = int.parse(anotherDateY) - int.parse(nowDateY);
//         if (year < 0) {
//           // 过去（今年以前）
//           return "${anotherDateY}年${anotherDateM}月${anotherDateD}日 ${anotherDateH}:${anotherDateMi}";
//         } else {
//           if (nowDateY == anotherDateY) {
//             // 今年
//             return "${anotherDateM}月${anotherDateD}日 ${anotherDateH}:${anotherDateMi}";
//           } else {
//             return "${anotherDateY}年${anotherDateM}月${anotherDateD}日 ${anotherDateH}:${anotherDateMi}";
//           }
//         }
//       } else {
//         return anotherDate;
//       }
//     } catch (e) {
//       return "${seconds}";
//     }
//   }
